/***************************************************************************
 * *   File name: TaskDispatcher.h
 * *    Describe: 业务处理分发类
 * *  Created on: 2016-8-6
 * *      Author: dengxiudong
 * *************************************************************************/
#ifndef _TASK_DISPATCHER_H_
#define _TASK_DISPATCHER_H_


#include "Protocol.h"

#include <map>
#include <memory>
#include <deque>
#include <mutex>
#include <condition_variable>

class TaskDispatcher
{
public:
    TaskDispatcher();
    ~TaskDispatcher();    
    void addTask(std::shared_ptr<Msg> msg);
    void getTask(std::deque<std::shared_ptr<Msg>> &taskQue);
    static TaskDispatcher* getInstance();
private:
    std::deque<std::shared_ptr<Msg>> m_taskQue;
    std::mutex m_mtx;
    std::condition_variable m_cond;

    static TaskDispatcher* m_instance;    
};

#endif
